package com.employeedemo.controller;

import com.employeedemo.entity.Employee;
import com.employeedemo.service.DateServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;
@RestController
@RequestMapping(value = "/employees")
public class EmployeeController {
    @Autowired
    private DateServices dateServices;

    @RequestMapping(value = "/",method = RequestMethod.GET)
    public List getEmployeeList() {
        return dateServices.getEmployeeList();
    }
    @RequestMapping(value = "/",method = RequestMethod.POST)
    public String postEmployee(@RequestBody Employee employee) {
    return dateServices.addEmployee(employee);
    }
    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public Employee getEmployee(@PathVariable Integer id) {
        return dateServices.getEmployeeByName(id);
    }
    @RequestMapping(value = "/{id}",method = RequestMethod.PUT)
    public String putEmployee(@PathVariable Integer id,@RequestBody Employee employee){
        return dateServices.updateEmployee(id,employee);
    }
    @RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    public String deleteEmployee(@PathVariable Integer id){
        return dateServices.deleteEmployee(id);
    }
}
